//------------层级结构------------
const String GET_PRODUCT_CATEGORIES_PARENT = '''
  query GetProductCategoriesParent(\$parent: Int!, \$first: Int, \$after: String) {
    productCategories(first: \$first, after: \$after, where: { parent: \$parent, order: ASC, orderby: TERM_ORDER,}) {
      pageInfo {
        hasNextPage
        endCursor
        offsetPagination {
          total
        }
      }
      nodes {
        menuOrder
        databaseId
        name
        slug
        count
        ... on ProductCategory {
          children {
            nodes {
              menuOrder
              databaseId
              name
              slug
              count
              children {
                nodes {
                  menuOrder
                  databaseId
                  name
                  slug
                  count
                }
              }
            }
          }
        }
      }
    }
  }
''';

//------------层级内容------------

const String GET_PRODUCTS_BY_CATEGORY_SLUG = '''
  query GetProductsByCategorySlug(
    \$first: Int,
    \$after: String,
    \$orderby: [ProductsOrderbyInput],
    \$featured: Boolean,
    \$categorySlug: String,
    \$stockStatus: [StockStatusEnum]
  ) {
    products(
      first: \$first,
      after: \$after,
      where: {
        orderby: \$orderby,
        category: \$categorySlug,
        featured: \$featured,
        status: "PUBLISH",
        stockStatus: \$stockStatus
      }
    ) {
      pageInfo {
        hasNextPage
        endCursor
        offsetPagination {
          total
        }
      }
      edges {
        node {
          databaseId
          name
          slug
          averageRating
          image {
            sourceUrl
          }
          ... on SimpleProduct {
            price
            salePrice
            regularPrice
            stockStatus
            galleryImages {
              nodes {
                sourceUrl
              }
            }
            productCategories {
              edges {
                node {
                  name
                  slug
                }
              }
            }
          }
          ... on VariableProduct {
            price
            salePrice
            regularPrice
            galleryImages {
              nodes {
                sourceUrl
              }
            }
            stockStatus
            productCategories {
              edges {
                node {
                  name
                  slug
                }
              }
            }
          }
        }
      }
    }
  }
''';

//----------------------------要传slug
const String PRODUCTBYSLUG_QUERY = """
  query GetProductBySlug(\$slug: [String]!) {
    products(where: { slugIn: \$slug }) {
      pageInfo {
        hasNextPage
        endCursor
        offsetPagination {
          total
        }
      }
      edges {
        node {
          databaseId
          name
          slug
          reviewCount
          averageRating
          image {
            sourceUrl
          }
          shortDescription
          description
          sku
          metaData(keysIn: ["woodmart_wc_video_gallery"]) {
            value
            id
            key
          }
          ... on SimpleProduct {
            link
            weight
            length
            width
            height
            price
            stockStatus
            stockQuantity
            salePrice
            regularPrice
            productTags {
              nodes {
                name
                databaseId
              }
            }
            attributes {
              nodes {
                attributeId
                visible
                label
                name
                options
              }
            }
            galleryImages {
              nodes {
                sourceUrl
              }
            }
            productCategories {
              edges {
                node {
                  name
                  slug
                }
              }
            }
          }
          ... on VariableProduct {
            attributes(first: 100) {
              nodes {
                variation
                visible
                label
                name
                options
              }
            }
            variations(first: 100) {
              nodes {
                stockStatus
                stockQuantity
                databaseId
                attributes(first: 100) {
                  nodes {
                    label
                    name
                    value
                  }
                }
                image {
                  sourceUrl
                }
                regularPrice
                price
                slug
              }
            }
            link
            weight
            length
            width
            height
            price
            stockStatus
            stockQuantity
            salePrice
            regularPrice
            productTags {
              nodes {
                name
                databaseId
              }
            }
            galleryImages {
              nodes {
                sourceUrl
              }
            }
            productCategories {
              edges {
                node {
                  name
                  slug
                }
              }
            }
          }
        }
      }
    }
  }
""";
